package com.example.reactor.rsocket.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.service.RSocketServiceProxyFactory;

/**
 * @author zpMeng
 * @since 10/11/2024
 */
@Configuration
public class ReactiveClientConfig {

    @Bean
    public RSocketServiceProxyFactory getRSocketServiceProxyFactory(RSocketRequester.Builder requestBuilder) {
        RSocketRequester requester = requestBuilder.tcp("localhost", 7000);
        return RSocketServiceProxyFactory.builder(requester).build();
    }

    @Bean
    public MessageClient messageClient(RSocketServiceProxyFactory factory) {
        return factory.createClient(MessageClient.class);
    }
}
